<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="./vue/vue.js"></script>
    <title>Document</title>
</head>

<body>
    <div id="demo">
        <input type="text" v-model="strA" /> <br />
        <input type="text" v-model="strB" /> <br />
        <span style="color:red;">{{whole}}</span>
    </div>

    <script>
        
        var vm = new Vue({
            el: "#demo",
            data: {
                strA:"strA",
                strB:"strB",
            },
            computed: {
                whole: {
                    get() {
                        console.log("getter called.");
                        return this.strA + "-" + this.strB;
                    },
                    set(value) {
                        console.log("setter called");
                        arr = value.split("-");
                        this.strA = arr[0];
                        this.strB = arr[1];
                    }
                }
            }
        });
    </script>
</body>

</html>